home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_55248.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  20 lines

  1. -- card: 55248 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. Suppose these classes are defined in the header files person.h and parent.h, each of which contains conditional compilation directives to prevent multiple inclusion.  The header 'person.h' must #include 'parent.h' to compile properly, which in turn must     #include 'person.h'!  However, since by this point 'person.h' has already begun compilation the conditional compilation feature will prevent its reinclusion.  This will prevent the successful compilation of 'parent.h'.
  11.  
  12. Instead, the following technique may be used.  One of the two headers ΓÇö parent.h ΓÇö may be written as usual, with a directive to #include person.h at the beginning of the file.  At the beginning of the file person.h must contain the line:
  13.  
  14.     struct    Parent;         /* inform the compiler that Parent is a struct "tag" */
  15.  
  16. This "tag" declaration is sufficient to complete the circular definition of the Person class, as long as references to 'Parent' are replaced by 'struct Parent'.  However, a source file which #includes person.h might require a complete definition of the Parent class.  This is ensured by placing a directive to #include parent.h at the END of the file person.h.
  17.  
  18. -- part contents for background part 7
  19. ----- text -----
  20. 179